Imports System.IO
Imports System.Text.RegularExpressions
Imports System.Xml

Public NotInheritable Class XmlString

    Private Const DECL_PATTERN As String = "^<[?]xml\s*version=""1[.]0""\s*(?<encoding>encoding\s*="".*?""\s*)?(?<standalone>standalone\s*="".*?""\s*)?[?]>"
    'Private Const DOCTYPE_PATTERN As String = "<!DOCTYPE(?:\s+)(?<Name>\S+)(?:(?:\s+)(?<ExternalId>.+?))?(?:\s+)?(?:\[(?<intSubset>[^]]+)\](?:\s+)?)?>"

    Private Shared ReadOnly DECL_REGEX As New Regex(DECL_PATTERN)
    'Private Shared ReadOnly DOCTYPE_REGEX As New Regex(DOCTYPE_PATTERN, RegexOptions.Singleline)

    'Public Shared Function RemoveDocType(ByVal xmlStr As String) As String

    '    Return DOCTYPE_REGEX.Replace(xmlStr, String.Empty)

    'End Function

    'Public Shared Function GetXmlReader(ByVal xmlWithoutDtd As String) As XmlReader

    '    Dim tr As New StringReader(xmlWithoutDtd)
    '    Dim xr As XmlReader = XmlReader.Create(tr)

    '    Return xr

    'End Function

    Public Shared Function HasDeclaration(ByVal xmlStr As String) As Boolean

        Return DECL_REGEX.IsMatch(xmlStr)

    End Function

    Private Sub New()

    End Sub
End Class
